//
//  SNSearchSectionFooterView.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/16.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "SNProductionSearchHistoryManager.h"
#import "SNProductionSearchSectionFooterView.h"
#import "Masonry.h"

@interface SNProductionSearchSectionFooterView()
/** mmButton */
@property(weak, nonatomic) UIButton * mmButton;
@end
@implementation SNProductionSearchSectionFooterView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UIButton * mmButton = ({
            UIButton * button = [[UIButton alloc] init];
            
            [button setTitle:@"清除搜索历史" forState:UIControlStateNormal];
            [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            button.layer.borderColor = HexRGB(0xafafaf).CGColor;
            button.layer.borderWidth = 1;
            button.layer.cornerRadius = 4;
            button.layer.masksToBounds = YES;
            button.titleLabel.font = [UIFont systemFontOfSize:13];
            
            // [button setImage:[UIImage imageNamed:@"normalImage"] forState:UIControlStateNormal];
            // [button setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateSelected];
            
            [button addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];
            
            // [self addSubview:button];
            // [self.contentView addSubview:button];
            [self addSubview:button];
            
            [button mas_makeConstraints:^(MASConstraintMaker * make) {
                make.centerX.mas_equalTo(self.mas_centerX).offset(0);
                make.bottom.mas_equalTo(self.mas_bottom).offset(0);
                
                make.width.mas_equalTo(100);
                make.height.mas_equalTo(30);
            }];
            
            button;
        });
        
        self.mmButton = mmButton;
        
        
    }
    return self;
}


-(void)btnClicked:(UIButton *)sender {
    NSLog(@"%s", __func__);
    
    [SNProductionSearchHistoryManager sharedManager].productionsearchHistoryModels = [NSMutableArray array];
    
    [SNProductionSearchHistoryModel clearTable];
    
    !self.reloadDataCollectionView ?: self.reloadDataCollectionView();
}
@end
